<?php
include_once(dirname(__FILE__).'/includes/JSON.php');
class JSONP{
	/**
	 * 
	 * @param  $code 结果码
	 * @param  $res 数组
	 * @return json
	 */
	public function JSONP($code,$res=array()){
		if(isset($_REQUEST['callback'])){
			$res    = array('code' => $code, 'result' => $res);
			return $_REQUEST['callback']."(".json_encode($res).")";
		}else{
			$res    = array('code' => $code, 'result' => $res);
			return json_encode($res);
		}
	}
}
